{% extends "smErp/base.html" %}

{% block css_style %}
    {% load staticfiles %}
    <link href="{% static 'smErp/css/register.css' %}" type="text/css" rel="stylesheet">
{% endblock %}

{% block content %}
    <!-- 二级导航 -->
    <div class="wrp_tab">
        <div class="tab">
            <ul id="appTabUl" class="tab_navs">
                <li apptype="brand" class="tab_nav first selected"><a href="javascript:void(0);" >品牌管理</a></li>
                <li apptype="product" class="tab_nav"><a href="javascript:void(0);" >产品管理</a></li>
                <li apptype="material" class="tab_nav"><a href="javascript:void(0);" >原料管理</a></li>
                <li apptype="suma" class="tab_nav last"><a href="javascript:void(0);" >溯码管理</a></li>
            </ul>
        </div>
    </div>

    <!-- 内容部分 -->
    <div id="data_box" class="data_box" style="display:block;">
    </div>
{% endblock %}

{% block footscript %}
    <script type="text/javascript" src="{% static 'smErp/js/common.js' %}"></script>
    <script>
        // 设置主菜单
        window.nav.selected("manage");
        function getCookie(c_name)
        {
            if (document.cookie.length>0)
            {
                c_start=document.cookie.indexOf(c_name + "=");
                if (c_start!=-1)
                {
                    c_start=c_start + c_name.length+1;
                    c_end=document.cookie.indexOf(";",c_start);
                    if (c_end==-1) c_end=document.cookie.length;
                    return unescape(document.cookie.substring(c_start,c_end))
                }
            }
            return ""
        }

        //
        function open_tab_nav(url){
            $.ajax({
                    url: url,
                    type:"GET",
                    success:function(data, status, xhr) {
                        $("#data_box").empty();
                        $("#data_box").html(data);
                    }
                }

            )
        }
        // nav切换
        function show_nav_page(apptype){
            if(apptype == "brand"){
                open_tab_nav("{% url 'smErp:manage_brand' %}");
            }else if(apptype == "product"){
                open_tab_nav("{% url 'smErp:manage_product' %}");
            }else if(apptype == "material"){
                open_tab_nav("{% url 'smErp:manage_material' %}");
            }
            else if(apptype == "suma"){
                open_tab_nav("{% url 'smErp:suma_manage' %}");
            }
        }


        // tab选项卡选择
        var selected = $("#appTabUl").children("li[class='tab_nav first selected']");
        $(".tab_nav").on('click',function(){
            selected.removeClass("selected");
            $(this).addClass("selected");
            selected = $(this);
            show_nav_page($(this).attr("apptype"));
        });
        selected.click();

        var selected_page = $("#m_menu_nav").children("li[class='menu_item first selected']");
        $(".menu_link").on('click',function(){
{#            alert($(this).data("page"));#}
            selected_page.removeClass("selected");
            $(this).parent().addClass("selected");
            selected_page = $(this).parent();
            show_menu_nav_page($(this).data("page"));

        });
        function goto_buy_suma(){
            $("#appTabUl").find("li[apptype='suma']").click();
        }

        function goto_publish_suma(){
            $("#appTabUl").find("li[apptype='suma']").click();
            $("#m_menu_nav").find("li[pagetype='suma_publish']").children("a").click();
        }
        // 弹窗显示图片
        function showBoxImage(obj) {
            var url = $(obj).attr('src');
            //iframe层-父子操作
            layer.open({
                type: 2,
                area: ['800px', '500px'],
                title: '图片：',
                fixed: true, //不固定
                maxmin: true,
                content: url
            });
        }
    </script>
{% endblock %}




